package com.tcs.job;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tcs.reptile.IReptileTask;
import com.tcs.reptile.ReptileTask;
import com.tcs.util.constant.SystemConstants;

/**
 * job执行
 * @author wangbo
 */
public class RequestJob extends AbstractRequestJob {
	
	private final Logger logger = LoggerFactory.getLogger(RequestJob.class);
	
	@Override
	public void work() {
		try {
			IReptileTask task = null;
			for (int i = 1;i <= super.getForNum(); i++) {
				Thread.sleep(1 * 1000L);
				this.requestParamsBean.setTmepUrl(super.requestParamsBean.getUrl() + super.requestParamsBean.getRule().replace(SystemConstants.ProxyPool.WEN, new Integer(i).toString()));
				logger.debug(" ---------------url : {} " , this.requestParamsBean.getTmepUrl());
				task = new ReptileTask(this.proxyPoolBean , super.requestParamsBean, this.countDownLatch);
				this.execute((Runnable)task);
			}
		} catch (Exception e) {
			logger.error("" , e);
		}
	}
}